﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

namespace Silver
{
    public class SilverData
    {
        public string  RetriveData()
        {
            //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://tool.cngold.org/plus/qjson.do?codes=CNYAAG,USDAAG&names=%E5%B7%A5%E8%A1%8C%E7%BA%B8%E7%99%BD%E9%93%B6%E4%BA%BA%E6%B0%91%E5%B8%81%E6%8A%A5%E4%BB%B7,%E5%B7%A5%E8%A1%8C%E7%BA%B8%E7%99%BD%E9%93%B6%E7%BE%8E%E5%85%83%E6%8A%A5%E4%BB%B7");

           HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://www.kitco.cn/KitcoDynamicSite/RequestHandler?requestName=getFileContent&AttributeId=PreciousMetalsSpotPricesCNY");
        
            HttpWebResponse myresponse = (HttpWebResponse)request.GetResponse();
            Stream mystream = myresponse.GetResponseStream();
            StreamReader sr = new StreamReader(mystream, System.Text.Encoding.GetEncoding("gb2312"));
            String html  = sr.ReadToEnd();
            sr.Close();
            return html;
        }

        public string Delete_tag(string html)
        {
            String pattern1 = "<(td)*?[^>]*>";
            Regex reg = new Regex(pattern1);

            string result = reg.Replace(html, "");
            return result;
        }
    }
}
